home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / installboot / installdec.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-02-17  |  2.0 KB  |  72 lines

  1. /* 
  2.  * installdec.c --
  3.  *
  4.  *    Check the header of a coff file.
  5.  *
  6.  * Copyright 1990 Regents of the University of California
  7.  * All rights reserved.
  8.  * Permission to use, copy, modify, and distribute this
  9.  * software and its documentation for any purpose and without
  10.  * fee is hereby granted, provided that the above copyright
  11.  * notice appear in all copies.  The University of California
  12.  * makes no representations about the suitability of this
  13.  * software for any purpose.  It is provided "as is" without
  14.  * express or implied warranty.
  15.  */
  16.  
  17. #ifndef lint
  18. static char rcsid[] = "$Header: /sprite/src/admin/installboot/RCS/installdec.c,v 1.1 90/02/16 16:12:07 shirriff Exp $ SPRITE (Berkeley)";
  19. #endif
  20.  
  21. #include <sprite.h>
  22. #include <kernel/ds3100.md/procMach.h>
  23. #include <stdio.h>
  24.  
  25.  
  26. /*
  27.  *----------------------------------------------------------------------
  28.  *
  29.  * DecHeader -
  30.  *
  31.  *    Check if the header is a dec (coff) file.
  32.  *
  33.  * Results:
  34.  *    An error code.
  35.  *
  36.  * Side effects:
  37.  *    None.
  38.  *
  39.  *----------------------------------------------------------------------
  40.  */
  41. ReturnStatus
  42. DecHeader(bootFID, loadAddr, execAddr, length)
  43.     int bootFID;    /* Handle on the boot program */
  44.     Address *loadAddr;    /* Address to start loading boot program. */
  45.     Address *execAddr;    /* Address to start executing boot program. */
  46.     int *length;    /* Length of the boot program. */
  47. {
  48.     ProcExecHeader aout;
  49.     int bytesRead;
  50.  
  51.     if (lseek(bootFID,0,0)<0) {
  52.     perror("");
  53.     return FAILURE;
  54.     }
  55.     bytesRead = read(bootFID, (char *)&aout, sizeof(ProcExecHeader));
  56.     if (bytesRead < 0) {
  57.     return FAILURE;
  58.     }
  59.     if (aout.aoutHeader.magic != PROC_OMAGIC) {
  60.     return FAILURE;
  61.     }
  62.     *loadAddr = (Address) aout.aoutHeader.codeStart;
  63.     *execAddr = (Address) aout.aoutHeader.entry;
  64.     *length = aout.aoutHeader.codeSize + aout.aoutHeader.heapSize;
  65.     if (lseek(bootFID,PROC_CODE_FILE_OFFSET(aout),0)<0) {
  66.     perror("");
  67.     return FAILURE;
  68.     }
  69.     printf("Input file is coff format\n");
  70.     return SUCCESS;
  71. }
  72.